<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 
	<jsp:include page="/AdminV3/include/main.jsp"></jsp:include>

 	<script type="text/javascript">
 	
 	
 			var job = Ext.data.Record.create([]);
 	
 			Ext.onReady(function(){
 				
 					var _grid = new Ext.grid.GridPanel({
 						renderTo:Ext.getBody(),
 						height:200,
 						id:'grid',
 						autoWidth:true,
 						enableColumnMove:false,
 						cm:new Ext.grid.ColumnModel([
 				                  					{header:'ID',dataIndex:'id',menuDisabled:true,align:'center'},
 				                  					{header:'笔名',dataIndex:'penName',menuDisabled:true,align:'center'},
 				                  					{header:'姓名',dataIndex:'perName',menuDisabled:true,align:'center'},
 				                  					{header:'密码',dataIndex:'password',menuDisabled:true,align:'center'},
 				                  					{header:'年龄',dataIndex:'age',menuDisabled:true,align:'center'},
 				                  					{header:'生日',dataIndex:'perbirthday',menuDisabled:true,align:'center'}
 				                  				]),
 						store : new Ext.data.Store({
	 							//data:[{name:'dtg',age:23,sex:'f'}],
	 							//fields:['perName','age','sex']
	 				    		
								proxy:new Ext.data.HttpProxy({url:'rest/UserService/selectApp'}),
								reader:new Ext.data.JsonReader({
								                totalProperty:'totalProperty',//最大多少条数据
								                 root:'root'
								},[
									{name:'id'},
									{name:'penName'},
									{name:'perName'},
									{name:'password'},
									{name:'age'},
									{name:'perbirthday'}
								  ]
								),
								listeners:{
									"beforeload":function(){
										
									}
								}
	 					}),
 						tbar:new Ext.PagingToolbar({
 							store:this.store,
 							pageSize:5,
 							autoWidth:true,
 							displayInfo:true,
 							displayMsg: '显示 {0} - {1} 条，共计 {2} 条',   
 							emptyMsg:'空'
 						}),
 						sm : new Ext.grid.RowSelectionModel({
 							singleSelect:true,
 							listeners:{
 								"rowselect":function(_sm,_index,_r){
 									Ext.getCmp("form").getForm().loadRecord(_r);
 								}
 							}
 						}),
 						listeners:{
 							"render":function(){
 								this.getStore().load({params:{start:0,limit:5}});
 							}
 						}
 					});
 					
 					var _form = new Ext.form.FormPanel({
							title:'用户信息',
							renderTo:new Ext.getBody(),
							frame:true,
							id:'form',
							defaultType:'textfield',
							items:[{
								fieldLabel:'姓名',
								name:'perName'
							},{
								fieldLabel:'笔名',
								name:'penName'
							},{
								fieldLabel:'生日',
								name:'perbirthday'
							}],
							buttons:[{
								text:'修改',
								handler:function(){
									var _selectModel =  Ext.getCmp("grid").getSelectionModel();
									if(_selectModel.getCount()==0){
										return;
									}
									var _values = this.ownerCt.ownerCt.getForm().getValues();
									var _rs = _selectModel.getSelected();
									_rs.set("perbirthday",_values['perbirthday']);
									_rs.set("penName",_values['penName']);
									_rs.set("perName",_values['perName']);
									_rs.commit();
									
								}
							}]
 					});
 					
			});
 	</script>
  </head>
  <body>
       
       
			<div id="grid"></div>  
			
	
  </body>
</html>
